#pragma once
#include "lockqueue.h"
#include <string>
// MPRPC框架提供的日志系统
enum LogLevel
{
    INFO,  // 普通级别
    ERROR, // 错判消息
};

class Logger
{
public:
    static Logger &GetInstance();
    void SetLogLevel(LogLevel level);
    void Log(std::string message);

private:
    int m_loglevel;
    LockQueue<std::string> m_queue; // 日志的缓冲队列
    Logger();
    Logger(const Logger &) = delete;
    Logger(Logger &&) = delete;
};

#define LOG_INFO(logmsgformat,...)\
    do{\
       Logger& logger = Logger::GetInstance();\
       logger.SetLogLevel(INFO);\
       char c[1024]={0};\
       snprintf(c,sizeof(c),logmsgformat,## __VA_ARGS__);\
       logger.Log(c);\
    }while(0);


#define LOG_ERR(logmsgformat,...)\
    do{\
       Logger& logger = Logger::GetInstance();\
       logger.SetLogLevel(ERROR);\
       char c[1024]={0};\
       snprintf(c,sizeof(c),logmsgformat,## __VA_ARGS__);\
       logger.Log(c);\
    }while(0);